{% extends "default/base.html" %}

{% block content %}
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-lg-12">
            <div class="ibox float-e-margins">
                <div id="ibox-content" class="ibox-title">
                    <h5> 权限分配详细信息列表 </h5>
                    <div class="ibox-tools">
                        <a class="collapse-link">
                            <i class="fa fa-chevron-up"></i>
                        </a>
                        <a class="dropdown-toggle" data-toggle="dropdown" href="#">
                            <i class="fa fa-wrench"></i>
                        </a>
                        <ul class="dropdown-menu dropdown-user">
                            <li><a href="#">未启用 1</a>
                            </li>
                            <li><a href="#">未启用 2</a>
                            </li>
                        </ul>
                        <a class="close-link">
                            <i class="fa fa-times"></i>
                        </a>
                    </div>
                </div>

                <div class="ibox-content">
                    {% include "auth/active.html" %}
                    <br/>
                    <div class="tab-content">
                        <table class="table table-striped table-bordered table-hover ">

                            <thead>
                                <tr>
                                    <th class="text-center"> <i class="glyphicon glyphicon-user"></i>角色名称 </th>
                                    <th class="text-center"> 角色描述 </th>
                                    <th class="text-center"> 成员人数 </th>
                                    <th class="text-center"> 状态 </th>
                                    <th class="text-center"> <li class="glyphicon glyphicon-cog"></li>管理操作 </th>
                                </tr>
                            </thead>

                            <tbody>
                            {% for i in data %}
                                <tr class="gradeX">
                                    <td class="text-center" id="username"> {{ i.group_name }} </td>
                                    <td class="text-center" id="ip"> {{ i.explanation }} </td>
                                    <td class="text-center" id="ip"> {% for k,v in group_user_count.items %} {% if k == i.uuid %}{{ v }}{% endif %}{% endfor %} </td>
                                    {% if i.enable %}
                                        <td class="text-center"><a href="/auth/cmdb/status/{{ i.uuid }}/" class="voilet_restart"><span class="glyphicon glyphicon-ok" aria-hidden="true" style="color:#2ad49e"></span></a> </td>
                                    {% else %}
                                        <td class="text-center"><a href="/auth/cmdb/status/{{ i.uuid }}/" class="voilet_restart"><span class="glyphicon glyphicon-remove" aria-hidden="true" style="color:#ff6846"></span> </a></td>
                                    {% endif %}
                                    <td class="text-center" id="start_time"> <a href="/auth/cmdb/group_auth/{{ i.uuid }}/" class="select_node"  >权限管理</a> |
                                        <a href="/auth/cmdb/group_user/{{ i.uuid }}/" class="select_node">成员管理</a> |
                                        <a href="/auth/cmdb/group_auth_edit/{{ i.uuid }}/" class="select_node"><li class="glyphicon glyphicon-pencil" style="color:#2ad49e"></li>修改</a> |
                                        <a href="/auth/cmdb/group_auth_delete/{{ i.uuid }}/"><li class="glyphicon glyphicon-trash" style="color:#ff6846"></li>删除</a>
                                    </td>
                                </tr>
                            {% endfor %}
                            </tbody>
                        </table>
                        <div class="row">
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
$(function() {
    $('.select_node').on('click', function (event) {
        var height = $(window).height(), index = $.layer({
            type: 2,
            shade: [0.5, '#000', true],
            shadeClose: true,
            maxmin: true,
            fix: true,
            moveOut: true,
            shift: 'top',
            border: [10, 0.3, '#000'],
            title: "权限分配",
            area: ['800px', (height - 50) + 'px'],
            //area : ['80%', (height - 50)+'px'],
            iframe: {src: $(this).attr('href')}
        });
        event.preventDefault();
    });

    $(document).on("click",".voilet_restart",function(e){
         e.preventDefault();
         var url= $(this).attr("href");
         $.layer({
            shade: [0],
            area: ['auto','auto'],
            dialog: {
                msg: '您确认要修改解角色状态',
                btns: 2,
                type: 4,
                title: '更改角色状态',
                btn: ['确认','取消'],
                yes: function(){
                    $.ajax({
                     type: "GET",
                     url: url }).done(function( data ) {
                     window.location.reload();
                 });
                }
            }
        });
     });


});
</script>

{% endblock content %}